<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Converter {
	public static function secs2Time($secs) {
		return sprintf("%d:%02d",$secs/3600,($secs%3600)/60);
	}

	public static function m2Km($distance) {
		$dis = $distance/1000;

		return sprintf("%.1f", $dis);
	}

	public static function time2Period($value) {
		list($years,$months) = Converter::days2YearsMonths($value);

		$period = $months." months";
		
		if ($years > 0) 
		  $period = $years." years - ".$period;

		return $period;
	}

	public static function days2YearsMonths($days) {
		$years = floor($days / 365);
		$months = ceil(($days % 365) / 30);
		
		return array($years,$months);
	}

}
?>